package servlet.Jamin;

import net.sf.json.JSONObject;
import service.impl.CouponServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
@WebServlet(value ="/DeleteCoupon")
public class DeleteCoupon extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String cid=req.getParameter("id");
        CouponServiceImpl sc=new CouponServiceImpl();
        JSONObject js=new JSONObject();
        PrintWriter out = resp.getWriter();
        int a=sc.deleteCoupon(Integer.parseInt(cid));
        if (a!=0){
            js.put("delete",true);
        }else{
            js.put("delete",false);
        }
        out.print(js);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
